package org.demo.rc.client;

/**
 * 定期更新图像
 * @author
 * @date 2010-10-23
 * @file org.demo.rc.client.ImageRefreshTask.java
 */
public class ImageRefreshTask implements Runnable {
	private MonitorClient parent;
	private int refresh_interval = 32;
	/**
	 * 构造函数
	 * @param parent
	 */
	public ImageRefreshTask(MonitorClient parent){
		this.parent = parent;
		refresh_interval = Integer.parseInt(
				                   parent.getProperties()
				                  .getProperty("refresh_interval", "32"));
	}
	/**
	 * 执行任务
	 */
	public void run() {
		while (!parent.isClosed()){
			try {
				parent.sendCommand("refresh");
				if (refresh_interval > 0){
					Thread.sleep(refresh_interval);
				}
			} catch(Exception e){
				System.out.println("img refresh task:> " + e.getMessage());
			}
		}
	}
}
